define(['app'],function(app){return {module: function($scope, $http, eventBusService, httpService, params) {

		$scope.form.father_id=params.father_id;

		httpService.post(app.urls.teacher_selectById,{"id":params.id},function(data){
			if("0000" === data.code){
				$scope.user = data.data;
				$scope.user.oldgadwpk = data.data.gzdwpk;
				$scope.user.oldrsdwpk = data.data.rsdwpk;
			}else{
				alert(data.msg);
			}
		});
		//查询所有单位
		httpService.post(app.urls.unit_selectCenterAndSchool,{},function(data){
			if("0000" === data.code){
				$scope.unitList = data.data;
			}else{
				alert(data.msg);
			}
		});
		//查询教职工类别
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10235"},function(data){
			if("0000" === data.code){
				$scope.jzglbms = data.data;
			}else{
				alert(data.msg);
			}
		});
		//查询性别码
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA29"},function(data){
			if("0000" === data.code){
				$scope.xbms = data.data;
			}else{
				alert(data.msg);
			}
		});
		//查询民族代码
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10002"},function(data){
			if("0000" === data.code){
				$scope.mzms = data.data;
			}else{
				alert(data.msg);
			}
		});
		//查询籍贯代码
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA31"},function(data){
			if("0000" === data.code){
				$scope.hksfList = data.data;
			}else{
				alert(data.msg);
			}
		});
		//查询国别码
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA35"},function(data){
			if("0000" === data.code){
				$scope.gjdqms = data.data;
			}else{
				alert(data.msg);
			}
		});
		//身份证件类型
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10236"},function(data){
			if("0000" === data.code){
				$scope.gjdqms = data.data;
			}else{
				alert(data.msg);
			}
		});
		//查询婚姻状况码 
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10012"},function(data){
			if("0000" === data.code){
				$scope.hyzkms = data.data;
			}else{
				alert(data.msg);
			}
		});
		//查询查询政治面貌代码 
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10006"},function(data){
			if("0000" === data.code){
				$scope.zzmmms = data.data;
			}else{
				alert(data.msg);
			}
		});
		//查询健康状况代码 
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10005"},function(data){
			if("0000" === data.code){
				$scope.jkzkms = data.data;
			}else{
				alert(data.msg);
			}
		});
		//查询户口性质代码
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10007"},function(data){
			if("0000" === data.code){
				$scope.hkxzms = data.data;
			}else{
				alert(data.msg);
			}
		});
		//查询编制类别(国)
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA36"},function(data){
			if("0000" === data.code){
				$scope.bzlbms = data.data;
			}else{
				alert(data.msg);
			}
		});
		//查询教师类别
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10223"},function(data){
			if("0000" === data.code){
				$scope.jslbms = data.data;
			}else{
				alert(data.msg);
			}
		});
		//查询专技职务资格
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA130"},function(data){
			if("0000" === data.code){
				$scope.zjzwzgms = data.data;
			}else{
				alert(data.msg);
			}
		});
		//查询所教学段
		httpService.post(app.urls.teacher_selectStage,{},function(data){
			if("0000" === data.code){
				$scope.sjxds = data.data;
			}else{
				alert(data.msg);
			}
		});
		//查询最高学位(学位代码)
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10023"},function(data){
			if("0000" === data.code){
				$scope.zgxws = data.data;
			}else{
				alert(data.msg);
			}
		});
		//查询外国语熟练程度码
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA42"},function(data){
			if("0000" === data.code){
				$scope.zwwycds = data.data;
			}else{
				alert(data.msg);
			}
		});
		//查询专业分类
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA90"},function(data){
			if("0000" === data.code){
				$scope.zyflms = data.data;
			}else{
				alert(data.msg);
			}
		});
		//查询宗教信仰代码
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10003"},function(data){
			if("0000" === data.code){
				$scope.xyzjms = data.data;
			}else{
				alert(data.msg);
			}
		});
		//查询血型代码
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10001"},function(data){
			if("0000" === data.code){
				$scope.xxms = data.data;
			}else{
				alert(data.msg);
			}
		});
		//查询港澳台侨外
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10240"},function(data){
			if("0000" === data.code){
				$scope.gatqwms = data.data;
			}else{
				alert(data.msg);
			}
		});
		//查询最高学历 
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10225"},function(data){
			if("0000" === data.code){
				$scope.zgxls = data.data;
			}else{
				alert(data.msg);
			}
		});
		//查询职称
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"j0ufs4tghd299dc9ukl57era4asd3425"},function(data){
			if("0000" === data.code){
				$scope.zcList = data.data;
			}else{
				alert(data.msg);
			}
		});
		//查询拔尖人才
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"a3dfc4dfws254dc6rfg44fgc2dbg904"},function(data){
			if("0000" === data.code){
				$scope.bjList = data.data;
			}else{
				alert(data.msg);
			}
		});
		$scope.saveForm = function(){
			if($scope.formCheck()) {
				$scope.user.id=$scope.user.fk_user=params.id;
				httpService.post(app.urls.teacher_selectRepeat,$scope.user,function(data) {
					if ("0000" === data.code) {
						// httpService.post(app.urls.user_update,$scope.user,function(data) {
						// 	if ("0000" === data.code) {
								httpService.post(app.urls.teacher_update, $scope.user, function (data) {
									if ("0000" === data.code) {
										$scope.error={};
										$scope.error.record = "'" + params.id + "'";
										$scope.error.sheet=params.sheet;
										$scope.error.field=params.field;
										$scope.error.type=params.type;
										httpService.post(app.urls.error_delete,$scope.error, function(data) {
											if ("0000" === data.code) {
												$scope.user.fk_unit = $scope.user.oldrsdwpk;
												$scope.user.new_unit = $scope.user.rsdwpk;
												$scope.user.type = '2';
												httpService.post(app.urls.user_unit_update,$scope.user,function(data){
													if("0000" === data.code){
														var menu = {"url": "modules/content/usermanagement/teacher/list?father_id=" + params.father_id+ "&sheet=" + params.sheet+ "&field=" + params.field+ "&type=" + params.type};
														if(params.sheet=='undefined'){
															eventBusService.publish("modules.content.load",menu);
														}else {
															eventBusService.publish("modules.content.load",menu);
														}
													}else{
														alert(data.msg);
													}
												});
											} else {
												alert(data.msg);
											}
										});
									} else {
										alert(data.msg);
									}
								});
						// 	}else {
						// 		alert(data.msg);
						// 	}
						// });
					} else {
						alert(data.msg);
					}
				});
			}
		}
		//返回
		$scope.goback = function(){
			var menu = {"url":"modules/content/usermanagement/teacher/list?father_id="+params.father_id};
			if(params.sheet!='undefined'){
				 menu.url = menu.url + "&sheet="+params.sheet;
				 eventBusService.publish("modules.content.load", menu);
			 }else{
				 eventBusService.publish("modules.content.load", menu);
			 }
		}
		//日期插件
		$('#'+$scope.controllerName+' .datepicker').datepicker({
			onSelect: function(dateText, inst) {
				eval("$scope." + $(this).attr('ng-model') + "='"+$(this).val()+"'");
			}
		});
		$('#'+$scope.controllerName+' .datepicker').datepicker('option', 'dateFormat','yy-mm-dd');//set dateFormat
	}}});